#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define filename "log.txt"
int main()
{
  fprintf(stdout,"hello nomal message\n");
  fprintf(stdout,"hello nomal message\n");
  fprintf(stdout,"hello nomal message\n");
  fprintf(stdout,"hello nomal message\n");
  fprintf(stdout,"hello nomal message\n");
  fprintf(stdout,"hello nomal message\n");
 
  fprintf(stderr,"hello error message\n");
  fprintf(stderr,"hello error message\n");
  fprintf(stderr,"hello error message\n");
  fprintf(stderr,"hello error message\n");

  //int fd=open(filename,O_WRONLY|O_CREAT|O_APPEND,0666);
  //if(fd<0)
  //{
  //  perror("open fail");
  //  return 1;
  //}
  //dup2(fd,1);
  //close(fd);
  //printf("%d\n",fd);
  //printf("hello linux\n");
  //fprintf(stdout,"hello fprintf\n");
  //char buffers[1024];
  //ssize_t s=read(0,buffers,sizeof(buffers)-1);
  //if(s>0)
  //{
  //  buffers[s]='\0';
  //  printf("echo:%s\n",buffers);
  //}
  //int fd=open(filename,O_CREAT|O_WRONLY|O_APPEND,0666);
  //if(fd<0)
  //{
  //  perror("open");
  //  return 1;
  //}
 
  //dup2(fd,1);
  //close(fd);
  //printf("%d\n",fd);
  //printf("hello linux\n");
 // const char* msg="hello linux\n";
 // int cnt=5;
 // while(cnt)
 // {
 //   write(1,msg,strlen(msg));
 //   cnt--;
 // }
  
  return 0;
}
